/**
 * 校验表单信息是否合法
 * @param {object} form 表单信息
 */
export function validateForm(form) {
  if (!form.name) return '请填写设备类型名称';
}

const ActiveList = {
  activeTrue: true,
  activeFalse: false
};

export function getActiveSelector() {
  const result = [];
  Object.values(ActiveList).forEach(active => {
    result.push({ value: active, label: getActiveDisplay(active) });
  });
  return result;
}

export function getActiveDisplay(active) {
  switch (active) {
    case ActiveList.activeTrue:
      return '启用';
    case ActiveList.activeFalse:
      return '不启用';
    default:
      return '未知';
  }
}

export function getActiveColor(active) {
  switch (active) {
    case ActiveList.activeTrue:
      return '#07c160';
    case ActiveList.activeFalse:
      return '#fa5151';
    default:
      return '#fff';
  }
}
